package thread;

public class SyncDemo2 {
    public static void main(String[] args) {
        Thread t1 = new Thread(Boo::doSomething);
        Thread t2 = new Thread(Boo::doSomething);
        t1.start();
        t2.start();
    }
}

class Boo{
    public static void doSomething() {
        synchronized (Boo.class) {
            try {
                Thread t = Thread.currentThread();
                System.out.println(t.getName() + "正在执行doSomething方法");
                Thread.sleep(3000);
                System.out.println(t.getName() + "执行doSomething方法完毕");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
